﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Common;
using DataAccess;

namespace BusinessLayer
{
    public class UsersBL
    {
        public void AddUser(Common.User u)
        {
            new UserRepository().AddUser(u);
        }

        /// <summary>
        /// Allow the user to login to the webiste but confirming that the username and email exists
        /// </summary>
        /// <param name="UserName"></param>
        /// <param name="Password"></param>
        /// <returns></returns>
        public bool UserLogin(string UserName, string Password)
        {
            return new UserRepository().UserLogin(UserName, Password);
        }

        /// <summary>
        /// Checking if the username already exists in the database
        /// </summary>
        /// <param name="username"></param>
        /// <returns></returns>
        public bool CheckUsernameExists(string username)
        {
            return new UserRepository().CheckUserNameExists(username);
        }

        /// <summary>
        /// Checking if the email already exists in the database
        /// </summary>
        /// <param name="email"></param>
        /// <returns></returns>
        public bool CheckEmailExists(string email)
        {
            return new UserRepository().CheckEmailExists(email);
        }

        /// <summary>
        /// Getting the menu pages according to the user roles
        /// </summary>
        /// <param name="roleId"></param>
        /// <returns></returns>
        public IEnumerable<Common.MainMenu> GetMenus(int roleId)
        {
            return new MenuRepository().getMenus(roleId).AsEnumerable();
        }
        /// <summary>
        /// Getting all Countries that are stored in the database
        /// </summary>
        /// <returns></returns>
        public IEnumerable<Common.Country> GetCountries()
        {
            return new LocationRepository().GetAllCountries();
        }


        /// <summary>
        /// Getting all Countries that are stored in the database
        /// </summary>
        /// <returns></returns>
        public IEnumerable<Common.Town> GetTowns()
        {
            return new TownRepository().GetAllTowns();
        }

        /// <summary>
        /// Getting a User that has the same inputted username 
        /// </summary>
        /// <param name="UserName"></param>
        /// <returns></returns>
        public Common.User GetUserByUserName(string UserName)
        {
            return new UserRepository().GetUserByUserName(UserName);
        }
    }

}
